#ifndef SERVERGAMEPLAYSTATE_H_
#define SERVERGAMEPLAYSTATE_H_

#include "GamePlayState.h"
#include "Server.h"
#include "Client.h"
#include "Players.h"

class ModelComposite;
class WellModel;

class ServerGamePlayState : public GamePlayState
{
public:
    ServerGamePlayState(ClientPtr client, ServerPtr server, PlayersPtr players, unsigned int widthOfWell);
    virtual ~ServerGamePlayState();

    virtual void init();
    virtual GameState* update(unsigned long msSinceLastLoop);
    virtual GameState* goToGameOverState(const std::string& winner);
    virtual GameState* leaveGame();

    virtual GameState* handleEvent(const Event& event);

private:
    void updateClients();
    void updateGravitationSpeed(unsigned long msSinceLastLoop);
    void movePiecesDown(unsigned long msSinceLastLoop);

    ServerPtr server;
    PlayersPtr players;
    ModelComposite* rootModel;
    WellModel* wellModel;
    ScoreModel* scoreModel;
    Uint32 msSinceLastMoveDown;
    Uint32 msSinceLastGravitationSpeedChange;
    Uint32 msGravitationSpeed;
};

#endif
